//
//  DHViewController.m
//  DHPopPathButton
//
//  Created by 306898641@qq.com on 02/09/2022.
//  Copyright (c) 2022 306898641@qq.com. All rights reserved.
//

#import "DHViewController.h"
#import <DHPopPathButton.h>

@interface DHViewController ()<DHPopPathButtonDelegate>

@end

@implementation DHViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    UITapGestureRecognizer *tap = [UITapGestureRecognizer.alloc initWithTarget:self action:@selector(tap:)];
    [self.view addGestureRecognizer:tap];
}

- (void)tap:(UITapGestureRecognizer *)ges {
    
    CGPoint point = [ges locationInView:ges.view];
    [self.view addSubview:({
        NSMutableArray *itemMar = [NSMutableArray array];
        NSArray *titleAr = @[@"预览",@"下载",@"分享",@"收藏"];
        for (int i = 0; i < titleAr.count; i ++) {
            DHPopPathItem *item = [DHPopPathItem itemWithTitle:titleAr[i] image:titleAr[i]];
            [itemMar addObject:item];
            
        }
        
        DHPopPathButton *btn = [DHPopPathButton popWithClickPoint:point
                                                            items:itemMar
                                                         delegate:self];
        btn;
    })];
}

#pragma mark - DHPopView delegate
- (void)DHPopPathButton:(DHPopPathButton *)btn didSelectIndex:(NSInteger)index {

    NSLog(@"点击了%ld个按钮",index);
}

- (void)DHPopPathButtonDidSelectCenterBtn {
    
    NSLog(@"点击了中间按钮");
}
@end
